export default Swiper

function Swiper(el) 
{
    this.el = document.querySelector(el)
    this.num = 1
    this.t = null
    this.Start()
}

Swiper.prototype.Start = function () 
{
    this.Dshi()
    this.Over()
}

Swiper.prototype.Dshi = function () 
{
    this.t = setInterval(() => 
    {
        this.num++
        if (this.num > 6) 
        {
            this.num = 1
        }
        this.el.querySelector('img').src = `./imgs/img${this.num}.jpg`
        this.page(this.num)
    }, 1000)
}

Swiper.prototype.page = function (num) 
{
    this.el.querySelector('ul li.active').className = ''
    this.el.querySelectorAll('ul li')[num - 1].className = 'active'
}
Swiper.prototype.Over = function () 
{
    let liobj = this.el.querySelectorAll('ul li')
    console.log(liobj.forEach);
    liobj.forEach((item, i) => 
    {
        item.onmouseover = () => 
        {
            clearInterval(this.t)
            this.el.querySelector('img').src = `./imgs/img${i+1}.jpg`
            this.num = i + 1
            this.page(this.num)
        }
        this.Out(item)
    })

}

Swiper.prototype.Out=function(item)
{
    item.onmouseout=()=>
    {
        this.Dshi()
    }
}